<link href="css/style_contact.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="css/jquery.lightbox-0.5.css" media="screen" />
<script type="text/javascript" src="js/jquery.lightbox-0.5.js"></script>
<script type= "text/javascript">
	Ext.onReady(function(){
		images.content(6);
		images.logo(6);
	});
</script>
<?php
    include('includes/contact.inc.php');
	$email = read_email();
require_once('phpmailer/class.phpmailer.php');

//Khởi tạo đối tượng
$mail = new PHPMailer();

/*=====================================
 * THIET LAP THONG TIN GUI MAIL
 *=====================================*/

$mail->IsSMTP(); // Gọi đến class xử lý SMTP
$mail->Host       = "mail.wheelhousecafe.net"; // tên SMTP server
//$mail->SMTPDebug  = 1; // enables SMTP debug information (for testing)
                                           // 1 = errors and messages
                                           // 2 = messages only
$mail->SMTPAuth   = true;                  // Sử dụng đăng nhập vào account
$mail->Host       = "mail.wheelhousecafe.net";         // Thiết lập thông tin của SMPT
$mail->Port       = 25;                    // Thiết lập cổng gửi email của máy
$mail->Username   = $email;         // SMTP account username
$mail->Password   = "@wheelhouse";                // SMTP account password

/*
	SET Value
*/

$from ="";
$message="";
$subject ="";
$fullname="";
if(isset($_POST["from"]) && isset($_POST["subject"]) && isset($_POST["message"])){
	$from = $_POST["from"];
	
	$message = $_POST["message"];
	$subject = $_POST["subject"];
	if(isset($_POST["fullname"])){
		$fullname = $_POST["fullname"];
		$mail->SetFrom($from,$fullname);
		$message= $message ."\n\n". $fullname;
	}else{
		$fullname = "Customer";
		$mail->SetFrom($from,$fullname);
	}
	if($from=="" or $subject=="" or $message==""){
	// echo "Please fill in ! " ;
	}else{
		$mail->AddAddress($email, "Wheel House Cafe");
		//Thiết lập email nhận email hồi đáp
		//nếu người nhận nhấn nút Reply
		$mail->AddReplyTo($from,$fullname);
		$mail->Subject = $subject;
		$mail->CharSet = "utf-8";
		$mail->Body = $message;
		if (!$mail -> Send()){
			echo "<script>alert('Errors . Server busy !')</script>";
		}else{
			echo "<script>alert('Email sent successfully !. Thanks')</script>";
		}
	}	
}
?>
<div id="content_and_footer">
	<div id="page_content">
		<div id="content">
			<div id="formemail">
				<form method="POST" action="?act=contact">
					<table style="width: 100%">
						<tr>
							<td style="width: 80px; font-size:12px"><strong>FULL NAME</strong></td>
							<td>								
								<input name="fullname" style="width: 250px; type="text" />								
							</td>
						</tr>
						<tr>
							<td style="width: 80px; font-size:12px"><strong>MAIL</strong></td>
							<td>								
								<input name="from" style="width: 250px; type="text" />							
							</td>
						</tr>
						<tr>
							<td style="width: 80px; font-size:12px"><strong>SUBJECT</strong></td>
							<td>
								<input name="subject" style="width: 250px; type="text" />
							</td>
						</tr>
						<tr>
							<td style="width: 80px; font-size:12px"><strong>MESSAGE</strong></td>
							<td rowspan="4">								
								<textarea name="message" style="width: 250px; height: 140px"></textarea>						
							</td>
						</tr>
						<tr>
							<td style="width: 80px; height: 32px;"></td>
						</tr>
						<tr>
							<td style="width: 80px">&nbsp;</td>
						</tr>
						<tr>
							<td style="width: 80px">&nbsp;</td>
						</tr>
						<tr>
							<td style="width: 80px">&nbsp;</td>
							<td style="text-align: center">								
								<input class="bnt_Sendmail" type="submit" value="Send" style="border-right:0px; border-left:0px; border-top:0px; border-bottom:0px; background:white; font-weight:bold" />								
							</td>
						</tr>
					</table>
				</form>
			</div>
			<div id ="content_map">
				<div id="content_contact">
				</div>
				<div id="map">
				</div>
			</div>
		</div>
		<div id="sidebar"">				
		</div>			
	</div>
	<div id="footer">
		Copyright © 2011 WHEEL HOUSE CAFE
	</div>
</div>
